import java.util.concurrent.RecursiveTask;

public class FibonacFork extends RecursiveTask<Integer> {
    final int n;
    FibonacFork(int n){
        this.n = n;
    }
    public int getN(){
        return this.n;
    }
    protected Integer compute(){
//        System.out.println(Thread.currentThread().getId()+" doing...");
        if(n<=1)
            return n;
        FibonacFork f1 = new FibonacFork(n-1);
        FibonacFork f2 = new FibonacFork(n-2);
        f1.fork();
        f2.fork();
        System.out.println(Thread.currentThread().getId()+" doing..."+f1.getN()+"...."+f2.getN() );
        return f1.join()+f2.join();
    }
}
